
/*
 * This code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public 
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this program; if not, write to the Free 
 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 
 * MA  02111-1307, USA.
 */
package asd.no.geosoft.cc.util;



/**
 * A number generated by the NiceNumbers class.
 * 
 * @author <a href="mailto:jacob.dreyer@geosoft.no">Jacob Dreyer</a>
 */   
public class NiceNumber
{
  private double  value_;
  private double  position_;  // Realtive. First is 0.0, last is 1.0
  private int     rank_;      // Major is 0, minor is 1, minorminor is 2 ...

  
  
  /**
   * Create a nice number.
   * 
   * @param value     Value of this nice number.
   * @param rank      Rank. Major is 0, next is 1 and so on.
   * @param position  Relative position among all nice numbers. First is 0.0,
   *                  last is 1.0 and so on.
   */
  NiceNumber (double value, int rank, double position)
  {
    value_    = value;
    rank_     = rank;
    position_ = position;
  }


  
  /**
   * Return the value of this nice number.
   * 
   * @return  Value of this nice number.
   */
  public double getValue()
  {
    return value_;
  }


  
  /**
   * Return the rank of this nice number.
   * 
   * @return  Rank of this nice number. Major is 0, next is 1 and so on.
   */
  public int getRank()
  {
    return rank_;
  }


  
  /**
   * Return the relative position of this value among all the nice numbers.
   * First is 0.0, last is 1.0 and so on.
   * 
   * @return  Relative position of this value among the nice numbers.
   */
  public double getPosition()
  {
    return position_;
  }
  
  
  
  /**
   * Create a string representation of this instance.
   * 
   * @return  A string representation of this class.
   */
  public String toString()
  {
    switch (rank_) {
      case 0  : return "==== " + Double.toString (value_);
      case 1  : return "--   " + Double.toString (value_);
      default : return "-    " + Double.toString (value_);  
    }
  }
}

